package com.saycode.back.articleType.service.impl;

import com.saycode.back.articleType.service.ContentTypeService;
import com.saycode.common.MethodUtil;
import com.saycode.common.beans.ContentType;
import com.saycode.common.dao.ContentTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Service("back/contentTypeService")
@RequestMapping("back/contentTypeService")
public class ContentTypeServiceImpl  implements ContentTypeService{

    @Autowired
    private ContentTypeRepository contentTypeRepository;
    @Override
    public List<ContentType> findAll() {
        return contentTypeRepository.findAll();
    }

    @Override
    public void save(String contentType) {
        ContentType content = new ContentType();
        content.setId(MethodUtil.getId());
        content.setContentType(contentType);
        contentTypeRepository.save(content);
    }

    @Override
    public void delete(Long id) {
        contentTypeRepository.delete(id);
    }
}
